package com.you.weixinpay.config;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import lombok.extern.slf4j.Slf4j;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Slf4j
public class Knife4jConfiguration {

    //  http://localhost:8090/doc.html
    @Bean
    public OpenAPI customOpenAPI() {

        return new OpenAPI().info(
                new Info()
                        .title("yzm支付案例练习")
                        .version("1.0")
                        .description("支付宝和微信支付相关的功能")
                        .contact(new Contact()
                                .name("yzm")
                                .url("https://space.bilibili.com/3461570046724468?spm_id_from=333.1007.0.0")
                                .email("8888888@qq.com"))
        );
    }

    @Bean
    public GroupedOpenApi WxPayAPI() {
        log.info("开始加载【微信支付】接口文档......");
        return GroupedOpenApi.builder().group("微信支付相关API").
                pathsToMatch("/api/wx-pay/**").build();
    }

    @Bean
    public GroupedOpenApi AliPayAPI() {
        log.info("开始加载【支付宝支付】接口文档......");
        return GroupedOpenApi.builder().group("支付宝支付相关API").
                pathsToMatch("/api/ali-pay/**").build();
    }

    @Bean
    public GroupedOpenApi productAPI() {
        log.info("开始加载【商品】接口文档......");
        return GroupedOpenApi.builder().group("商品相关API").
                pathsToMatch("/api/product/**",
                        "/api/order-info/**"
                ).build();
    }

}
